package com.bigflexlib.core.async
{
	
	import flash.events.Event;
	import flash.events.HTTPStatusEvent;
	import flash.events.IOErrorEvent;
	import flash.events.SecurityErrorEvent;
	import flash.net.URLLoader;


	public class URLLoaderAsyncWrapper extends AsyncWrapper
	{
		
		private var loader:URLLoader;
		
		public function URLLoaderAsyncWrapper( target:URLLoader )
		{
			super( target );
			loader = target;
			
			loader.addEventListener( Event.COMPLETE, loader_complete );
			
			loader.addEventListener( HTTPStatusEvent.HTTP_STATUS, loader_httpStatus );
			loader.addEventListener( IOErrorEvent.IO_ERROR, loader_ioError );
			loader.addEventListener( SecurityErrorEvent.SECURITY_ERROR, loader_securityError );
		}
		
		private function loader_complete( event:Event ):void
		{
			informResult( loader.data );			
		}
		
		
		private function loader_httpStatus( event:HTTPStatusEvent ):void
		{
			informFault( null, event );
		}
		
		private function loader_ioError( event:IOErrorEvent ):void
		{
			informFault( null, event );
		}

		private function loader_securityError( event:SecurityErrorEvent ):void
		{
			informFault( null, event );
		}		
		
	}
}